package cn.jietuo.first.class02;

/**
 * @author zhangx & jietuo_zx@163.com
 * @version 1.0
 * @date 2020/6/18
 * @description: 使用递归求出数组L-R范围上的最大值
 */
public class Code08_GetMax {

    public static int process(int[] arr,int l,int r){
        if (l == r){
            return arr[l];
        }
        //拿到中点
        int mid = l + (r - l)/2;
        int leftMax = process(arr,l,mid);
        int rightMax = process(arr,mid + 1,r);
        return Math.max(leftMax,rightMax);
    }

    public static void main(String[] args) {
        int[] arr = new int[]{2,3,5,1,65,23,867,435};
        int process = process(arr, 0, arr.length -1);
        System.out.println(process);
    }
}
